<template>
  <div class="approvals">
    审批
    <pageTools :showBefore="true">
      <template v-slot:before
        >当前审批中 0 本月审批通过 1 本月审批驳回 0</template
      >
      <template v-slot:after>
        <el-button type="primary">流程设置</el-button>
      </template>
    </pageTools>
    <!--  -->
    <el-card>
      <el-table :data="list">
        <el-table-column type="selection" width="30px"></el-table-column>
        <el-table-column label="序号" type="index"> </el-table-column>
        <el-table-column label="审批类型" prop="processName"></el-table-column>
        <el-table-column label="申请人" prop="username"></el-table-column>
        <el-table-column
          label="当前审批人"
          prop="procCurrNodeUserName"
        ></el-table-column>
        <el-table-column label="审批发起时间">
          <template v-slot="{ row }">
            <div>{{ row.procApplyTime | formatTimePus }}</div>
          </template>
        </el-table-column>
        <el-table-column label="审批状态" prop="processState">
          <template v-slot="{ row }">
            <span v-if="row.processState === '0'" class="rovalsState">
              <em class="sub" />已提交
            </span>
            <span v-if="row.processState === '1'" class="rovalsState">
              <em class="stay" />审批中
            </span>
            <span v-if="row.processState === '2'" class="rovalsState">
              <em class="adopt" />审批通过
            </span>
            <span v-if="row.processState === '3'" class="rovalsState">
              <em class="reject" />审批不通过
            </span>
            <span v-if="row.processState === '4'" class="rovalsState">
              <em class="revoke" />撤销
            </span>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <el-button type="text" @click="submit">查看</el-button>
        </el-table-column>
      </el-table>
      <!-- 分页组件 -->
      <el-row type="flex" align="middle" justify="center" style="height: 60px">
        <el-pagination
          @size-change="sizeChange"
          @current-change="pageChange"
          :current-page="page.page"
          :page-sizes="[10, 20, 300, 400]"
          :page-size="page.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="page.total"
        >
        </el-pagination>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { userProcessInstancePut } from '@/api/approvals.js'
export default {
  data () {
    return {
      list: [],
      page: {
        page: 1,
        total: 0,
        size: 10
      }
    }
  },
  created () {
    this.getData()
  },
  methods: {
    async getData () {
      const res = await userProcessInstancePut(this.page)
      this.list = res.data.rows
      this.page.total = res.data.total
      console.log('审批', res)
    },
    pageChange (page) {
      this.page.page = page
      this.getData()
    },
    sizeChange (size) {
      this.page.size = size
      this.page.page = 1
      this.getData()
    },
    submit(row){
let name=row.processName
switch (name){
  case '工资':
    break
}
    }
  }
}
</script>

<style></style>
